package com.yjlove.myplay.base;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import com.umeng.analytics.MobclickAgent;
import com.yjlove.myplay.R;

/**
 * 作者 YJlvoe
 * 创建时间 2017/1/20.
 */
public abstract class BaseActivity extends AppCompatActivity {

    protected Activity mActivity;
    private TextView mTitle;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getActivityView());

        mActivity = BaseActivity.this;
        mTitle = (TextView) findViewById(R.id.title);
        mTitle.setText(getActivityTitle());

        MobclickAgent.setDebugMode(false);//开启/关闭调试模式（true，如果不开启debug运行不会上传umeng统计）
        MobclickAgent.setCheckDevice(false);//不采集手机mac地址
        MobclickAgent.openActivityDurationTrack(false);// 禁止默认的页面统计方式，这样将不会再自动统计Activity。
        MobclickAgent.setScenarioType(mActivity, MobclickAgent.EScenarioType.E_UM_NORMAL);//设置场景模式为普通

        initView();
        initData();
    }
    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onPageStart("BaseActivity");
        MobclickAgent.onResume(mActivity);
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd("BaseActivity");
        MobclickAgent.onPause(mActivity);
    }
    protected abstract String getActivityTitle();

    protected abstract int getActivityView();

    protected abstract void initView();

    protected abstract void initData();
}
